package com.hjw.weixun.action;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.hjw.weixun.domain.User;
import com.hjw.weixun.domain.Weixun;
import com.hjw.weixun.service.FollowerService;
import com.hjw.weixun.service.UserService;
import com.hjw.weixun.service.impl.FollowerServiceImpl;
import com.hjw.weixun.service.impl.UserServiceImpl;

/**
 * 用于处理粉丝相关请求
 * 
 * @author wangchangxin date 2011-8-19 FollowerAction
 * 
 */
public class FollowerAction extends GenericAction {

	private static final long serialVersionUID = 7249807172345063600L;

	private static final Logger logger = LoggerFactory
			.getLogger(FollowerAction.class);

	private FollowerService followerService;

	private UserService userService;

	private Weixun weixun;

	// 单列
	public FollowerAction() {
		userService = UserServiceImpl.getInstance();
		followerService = FollowerServiceImpl.getInstance();
	}

	public String addFollower() {

		User user = super.getCurrentUser();

		if (null == user || null == weixun) {
			return null;
		}

		followerService.addFollower(weixun, user);
		renderHtml("{\"success\":\"true\"}");

		return null;

	}

	public Weixun getWeixun() {
		return weixun;
	}

	public void setWeixun(Weixun weixun) {
		this.weixun = weixun;
	}

}
